package com.code.translate.httpbuilder;

import com.alibaba.fastjson.JSON;
import org.springframework.http.MediaType;

import java.io.IOException;
import java.io.OutputStream;
import java.util.Map;

/**
 * @author ggh
 * @date 2022/8/9
 */
public class ApplicationJsonBuilder extends ContentTypeBuilder {

    @Override
    public void bodybuilder(OutputStream os, Map<String, Object> params) throws IOException {
//        os.write(params.get("json").toString().getBytes());
        os.write(JSON.toJSONString(params).getBytes());
    }

    @Override
    public boolean isPresent(String content) {
        return content.contains(MediaType.APPLICATION_JSON_VALUE);
    }
}
